package com.yinhai.controller;

import com.yinhai.domain.ResponseResult;
import com.yinhai.domain.User;
import com.yinhai.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : chengxd
 * @create 2024/2/13 21:42
 */
@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("user/login")
    public ResponseResult login(@RequestBody User user){
        ResponseResult result = loginService.login(user);
        return result;
    }

    @PostMapping("user/logout")
    public ResponseResult logout(){
        ResponseResult result = loginService.logout();
        return result;
    }
}
